<template>
	<view>
		<chealth ref="chealth"></chealth>
		<shortcut ref="shortcut" style="animation-duration: 500ms" class="animated fadeIn" :infos="iscard" :child='idx' v-show="isShowMenu" @closeMenu="closeMenu"></shortcut>
	</view>
</template>

<script>
	import shortcut from '../../components/shortcut/shortcut.vue'
	import chealth from '../main/child/chealth.vue' // 儿童-健康管理
	export default {
		components: {
			shortcut,
			chealth,
		},
		data() {
			return {
				isShowMenu: false,
				iscard: "",
				idx: '', //营养包
			};
		},
		onPageScroll(e) {
			this.$refs.chealth.scroll(e.scrollTop)
		},
		onPullDownRefresh() {
			//监听下拉刷新动作的执行方法，每次手动下拉刷新都会执行一次
			//console.log('refresh');
			setTimeout(function() {
				uni.stopPullDownRefresh(); //停止下拉刷新动画
			}, 1000);
			this.$refs.chealth.refreshPage()
		},
		onReachBottom() {
			this.$refs.chealth.getMoreList()
		},
		methods: {
			closeMenu(msg) {
				this.isShowMenu = false;
			},
			getIdx() {
				this.config.get('/flow/getUserNutrition').then((res) => {
					console.log(res)
					this.idx = res.data.data
				})
			},
			isReport() {
				let self = this;
				this.config.get('/initUser/pdCommonIsArchives', {}).then(({
					data: {
						data
					}
				}) => {
					// console.log(data)  //1显示  0不显示
					this.iscard = data;
				})
			}
		},
		mounted() {
			uni.onTabBarMidButtonTap(s => {
				this.isShowMenu = !this.isShowMenu;
			})
		},
		onShow() {
			this.isShowMenu = false;
			setTimeout(s => {
				this.$refs.chealth.refreshPage()
				this.isReport()
				this.getIdx()
				this.$refs.chealth.getBallInfo()
				this.$refs.chealth.getNewList()
			}, 300)
		}
	}
</script>

<style scoped>

</style>
